﻿package morn.core.components
{
    import flash.events.*;
    import flash.text.*;

    public class TextInput extends Label
    {

        public function TextInput(param1:String = "", param2:String = null)
        {
            super(param1, param2);
            return;
        }// end function

        override protected function initialize() : void
        {
            super.initialize();
            width = 128;
            height = 22;
            selectable = true;
            _textField.type = TextFieldType.INPUT;
            _textField.autoSize = "none";
            _textField.addEventListener(Event.CHANGE, this.onTextFieldChange);
            _textField.addEventListener(TextEvent.TEXT_INPUT, this.onTextFieldTextInput);
            return;
        }// end function

        private function onTextFieldTextInput(event:TextEvent) : void
        {
            dispatchEvent(event);
            return;
        }// end function

        protected function onTextFieldChange(event:Event) : void
        {
            text = _textField.text;
            return;
        }// end function

        public function get restrict() : String
        {
            return _textField.restrict;
        }// end function

        public function set restrict(param1:String) : void
        {
            _textField.restrict = param1;
            return;
        }// end function

        public function get editable() : Boolean
        {
            return _textField.type == TextFieldType.INPUT;
        }// end function

        public function set editable(param1:Boolean) : void
        {
            _textField.type = param1 ? (TextFieldType.INPUT) : (TextFieldType.DYNAMIC);
            return;
        }// end function

        public function get maxChars() : int
        {
            return _textField.maxChars;
        }// end function

        public function set maxChars(param1:int) : void
        {
            _textField.maxChars = param1;
            return;
        }// end function

    }
}
